export default {
    name: 'Modifypass',
    components: {

    },
    data() {
        return {
            modifypass: {
                oldPass: '',
                newPass: '',
                newPassAgain: ''
            },
            formLabelWidth: '120px',
            userInfo: ''
        }
    },
    computed: {

    },
    watch: {

    },
    created() {
        this.userInfo = JSON.parse(window.localStorage.getItem('userInfo'));
    },
    mounted() {

    },
    methods: {
        /**修改密码*/
        modifyPass() {
            var passRule = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,10}$/; //密码正则
            if (!passRule.test(this.modifypass.newPass)) {
                this.$message.error('密码由英文和数字组合,6-10位');
                return;
            }
            if (this.modifypass.newPassAgain == "") {
                this.$message.error('请再次输入密码确认');
                return;
            }
            if (this.modifypass.newPass != this.modifypass.newPassAgain) {
                this.$message.error('密码不一致');
                return;
            }
            this.$http.get('/userController/updatePasswordByUId?uId=' + this.userInfo.uId + '&password=' + this.modifypass.newPass)
                .then((res) => {
                    if (res.status == 200) {
                        this.$message({
                            type: 'success',
                            message: res.message
                        });
                        this.modifyPass = {
                            newPass: '',
                            newPassAgain: ''
                        };
                        return false;
                    }
                    this.$message.error(res.message);
                })
                .catch((res) => {
                    console.log(res);
                })
        }
    }
}